package com.cloud.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cloud.mall.entity.User;
import com.cloud.mall.mapper.UserMapper;
import com.cloud.mall.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 芋头同学
 * @since 2021-08-20
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    /**
     * 查询用户并比对密码是否正确
     * @param user 包含用户账户和密码的用户信息
     * @return 查询到的用户
     */
    @Override
    public User login(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("account",user.getAccount());
        queryWrapper.eq("password",user.getPassword());
        User one = baseMapper.selectOne(queryWrapper);
        return one;
    }
}
